/*
* Copyright (c) 2025 Huawei Device Co., Ltd.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including but not limited to the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to provide persons with access to the Software
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGE OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

<template>
  <div class="container-header" :style="containerStyle">
    <img
      class="playlist-image"
      src="@/assets/playList/cover.png"
      alt="Playlist cover"
    />
    <span class="image-number">{{ imageNumber }}</span>
    <h1 class="text-title">{{ playlistTitle }}</h1>
    <p class="text-description">{{ playlistDescription }}</p>
    <p class="author">Christopher</p>

    <div class="images-row">
      <img
        v-for="(image, index) in fourImages"
        :key="index"
        :src="image"
        class="four-image"
        :alt="'Action button ' + index"
      />
    </div>
  </div>
</template>

<script lang="ts">
export default {
  name: 'NewPlaylistHeaderTable',
  props: {
    bottomAvoidArea: {
      type: Number,
      default: 0,
    },
  },
  data() {
    return {
      imageNumber: '3456万',
      playlistTitle: '轻快旋律：这里是疲倦灵魂栖息地',
      playlistDescription:
        '怀旧使我快乐，人们总是以为自己的生活很枯燥/乏味，那是因为他们没有回过头来聆听那些曾陪伴过我们青春的旋律',
      fourImages: [
        require('@/assets/playList/love_count.png'),
        require('@/assets/playList/download_count.png'),
        require('@/assets/playList/commen_count.png'),
        require('@/assets/playList/share.png'),
      ],
      containerStyle: {},
    };
  },
  mounted() {
    this.$nextTick(()=>{
       this.handleResize();
    });
    window.addEventListener('resize', this.handleResize);
  },
  beforeDestroy() {
    window.removeEventListener('resize', this.handleResize);
  },
  methods: {
    handleResize() {
      const height = window.innerHeight + (this.bottomAvoidArea ? 0 : 30);
      this.containerStyle = {
        height: `${height * 0.75}px`,
        width: `${(height * 0.75 * 384) / 596}px`,
        backgroundImage: `url(${require('@/assets/playList/header_background_table.png')})`,
      };
    },
  },
};
</script>

<style scoped>
.container-header {
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-left: 32px;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  position: relative;
}

.playlist-image {
  width: 73%;
  height: 47%;
  margin-top: 9.3%;
  object-fit: cover;
}

.image-number {
  color: rgba(255, 255, 255, 0.86);
  font-size: 12px;
  position: absolute;
  left: 15%;
  top: 50%;
}

.text-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.86);
  margin-top: 6%;
  width: 83%;
  height: 13.4%;
  text-align: center;
}

.text-description {
  margin-top: 2%;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
  width: 83%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.author {
  margin-top: 2%;
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.6);
  line-height: 19px;
}

.images-row {
  display: flex;
  flex-direction: row;
  margin-top: 4%;
  margin-bottom: 4%;
  width: 87.5%;
  justify-content: space-between;
}

.four-image {
  width: 48px;
  height: 48px;
}
</style>
